﻿/******************************************************************************
 *  作者：       scott
 *  创建时间：   2012/3/3 21:05:29
 *
 *
 ******************************************************************************/

using System.Collections.Generic;
using EasyMvcBlog.Data;

namespace EasyMvcBlog.Infrastructure.Repository.DataRepository
{
    public class BlogRepository : RepositoryBase<Blog>
    {
        public string GetByKey(string key)
        {
            List<Blog> blogSettings = GetList(blog => blog.BlogKey == key);
            if (blogSettings.Count > 0)
            {
                return blogSettings[0].BlogValue;
            }
            return string.Empty;
        }

        public bool SetKeyValue(string key, string value)
        {
            List<Blog> blogSettings = GetList(blog => blog.BlogKey == key);
            if (blogSettings.Count > 0)
            {
                blogSettings[0].BlogValue = value;
                Update(blogSettings[0]);
                return true;
            }
            return false;
        }
    }
}
